import Vue from 'vue'
import Vuex from 'vuex'
import { getItem, setItem, removeItem } from '@/utils/storage'
Vue.use(Vuex)
// 存储token
const TOKEN_KEY = 'TOKEN_KEY'
export default new Vuex.Store({
  state: {
    user: getItem(TOKEN_KEY)
  },
  mutations: {
    USERTOKEN (state, obj) {
      setItem(TOKEN_KEY, obj)
      state.user = obj
    },
    // 清除用户token
    USERLOGOUT (state) {
      removeItem(TOKEN_KEY)
      state.user = null
    }
  },
  actions: {
  },
  modules: {
  }
})
